/* ***********************
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is briefNameAndLink.js module.
 *
 * The Initial Developer of the Original Code is Rob Gerns.
 *
 * Portions created by the Initial Developer are Copyright (C) 2011
 * the Initial Developer. All Rights Reserved.
 *
 **************************/
function getBriefNameAndLink(objXmlDocument) { 
    /*************************************************
    * Function Name: getBriefNameAndLink
    *
    * Purpose: Check to see if site name and site link are defined,
    * if so then retrieve the value of each.
    ***************************************************/   
    var objBriefLink = objXmlDocument.getElementsByTagName("sitelink");
    var intBriefLinkCount = objBriefLink.length;
    var objBriefName = objXmlDocument.getElementsByTagName("sitename");
    var intBriefNameCount = objBriefName.length;
    //Make sure sitelink value exists, otherwise make it blank.
    if (intBriefLinkCount > 0  && intBriefLinkCount !== undefined) {
        strBriefLink = objBriefLink.item(0).firstChild.data;
    }
    else {
        strBriefLink = "";  
    } 
    //Make sure sitename value exists, otherwise make it blank.
    if (intBriefNameCount > 0 && intBriefNameCount !== undefined) {
        strBriefName = objBriefName.item(0).firstChild.data;
    }
    else {
        strBriefName = ""; 
    }
    //Call the writeBriefNameAndLink function to create the appropriate div.
    writeBriefNameAndLink(strBriefName,strBriefLink);
}
function writeBriefNameAndLink(strBriefName,strBriefLink) {
    /*************************************************
    * Function Name: writeBriefNameAndLink
    *
    * Purpose: Create the div that contains the brief 
    * site name.  Make the site name into a link using the
    * information retrieved from the Oister feed.
    ***************************************************/
    var objDivSiteName = "";
    var objDivSiteNameId = "";
        
    objDivSiteName = document.createElement("div");
    objDivSiteNameId = objDivSiteName.id = "sitename";
    objDivSiteName.className = "sitename";
    document.getElementById('begin').appendChild(objDivSiteName);
    objDivSiteName.innerHTML = "<a href=\"" + strBriefLink + "\" class=\""
        + "sitetitle\"" + ">" + strBriefName + "</a>";
}